package org.opens.netty.chatServer.server.service.impl;

import org.opens.netty.chatServer.server.service.UserService;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class UserServiceMemoryImpl implements UserService {

    /**
     * 模拟数据库
     */
    private static Map<String, String> userMap = new ConcurrentHashMap<>();

    static {
        userMap.put("zhangsan", "123");
        userMap.put("lisi", "123");
        userMap.put("wangwu", "123");
        userMap.put("zhaoliu", "123");
        userMap.put("qianqi", "123");
    }

    @Override
    public boolean login(String username, String password) {
        String pass = userMap.get(username);
        if (pass == null) {
            return false;
        }
        return pass.equals(password);
    }

}
